package com.aliang.shardingjdbcdemo.service;

import com.aliang.shardingjdbcdemo.dao.OrderMapper;
import com.aliang.shardingjdbcdemo.entity.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: chendongliang
 * @Date: 2019/8/23 17:11
 */
@Service
public class OrderService {

    @Autowired
    OrderMapper orderMapper;

    public void getOrders(Order order){
        order.setUserId(1L);
        order.setOrderId(1L);

        orderMapper.deleteOrder();

        Order order1 = new Order(7L,7L);
        orderMapper.addOrder(order1);


        List<Order> result = orderMapper.getOrders(order);


        Order order2 = new Order(6L,6L);
        //orderMapper.updateOrder(order2);

        result.forEach(o-> System.out.println(o.getUserId()+"----------"+o.getOrderId()));
    }

}
